package com.itestor.iptv.global.utils;

public class ITestStringUtil {
    
    
    /**
     * 
     * @param line
     * @param oldString
     * @param newString
     * @return String
     */
    public static String replace(String line, String oldString,String newString){  
        
        if (line == null) {  
     
          return null;  
     
        }  
     
        int i = 0;  
     
        if ( (i = line.indexOf(oldString, i)) >= 0) {  
     
          char[] line2 = line.toCharArray(); //字符串放入数组  
     
          char[] newString2 = newString.toCharArray(); //要替换的字符串  
     
          int oLength = oldString.length(); //被替换的字符串的长度  
     
          StringBuffer buf = new StringBuffer(line2.length);  
     
          buf.append(line2, 0, i).append(newString2);  
     
          i += oLength;  
     
          int j = i;  
     
          while ( (i = line.indexOf(oldString, i)) > 0) {  
     
            buf.append(line2, j, i - j).append(newString2);  
     
            i += oLength;  
     
            j = i;  
     
          }  
     
          buf.append(line2, j, line2.length - j);  
     
          return buf.toString();  
     
        }  
     
        return line;  
     
      }  
    
    
    public static void main(String[] args) {
        String ss="http://127.0.0.1/itest\\2010-09-25\\18-26-40.015-ES.mp4";
                
        
       
        
        String ssssss=ss.replace('\\','/');
        
        
        
        System.out.println("ssssssss"+ssssss);
    }

}
